﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DataService;
using DTO;

public partial class Server_Device_EditServer : BasePage
{
    private DeviceService _service;
    private int DeviceId = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (UserLogin != null)
        {
            if(!string.IsNullOrEmpty(Request.QueryString["Deviceid"]))
            {
                try
                {
                    DeviceId = Convert.ToInt32(Request.QueryString["Deviceid"]);
                }
                catch
                {
                    Response.Redirect("default.aspx");
                }
            }
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (DeviceId > 0 && UserLogin != null)
        {
            _service = new DeviceService();
            _service.UpdateDeviceFriendlyNameByDeviceId(DeviceId, txtFriendlyName.Text, textArea.Value);
            Response.Redirect("default.aspx");
        }
    }
}